{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
.childrenBody {
    background: #fff;
}
</style>
<table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>

{/block}
{block name="script"}
<script>
layui.use(['table', 'yznTable'], function() {
    var table = layui.table,
        $ = layui.$,
        form = layui.form,
        table = layui.table,
        yznTable = layui.yznTable;

    var init = {
        table_elem: '#currentTable',
        add_url: "{:url('add')}",
        delete_url: "{:url('del')}",
        export_url: "{:url('export')}",
    };

    yznTable.render({
        init: init,
        id: 'currentTable',
        elem: '#currentTable',
        toolbar: ['refresh',
            [{
                text: '添加',
                url: init.add_url,
                method: 'open',
                icon: 'iconfont icon-add',
                class: 'layui-btn layui-btn-normal layui-btn-sm',
            }], 'delete',
            [{
                html: '<a class="layui-btn layui-btn-sm " data-open="{:url("export")}"><i class="iconfont icon-cloud-download"></i>&nbsp;导出二维码</a>\
                <a class="layui-btn layui-btn-sm " href="{:url("exportExcel")}"><i class="iconfont icon-cloud-download"></i>&nbsp;导出Excel</a>'
            }],
        ],
        url: '{:url("index")}',
        cols: [
            [
                { type: 'checkbox', fixed: 'left' },
                { field: 'id', title: 'ID' },
                { field: 'code',  title: '编码' },
                { field: 'qrcode',  title: '二维码', search: false, templet: yznTable.image },
                { field: 'url',  title: '链接', search: false},
                { field: 'create_time',  title: '创建时间', search: 'range' },
                { field: 'download',  title: '状态', selectList: { 0: '未下载', 1: '已下载' }, templet:function(d){
                    if(d.download == 1){
                        return '已下载'
                    }else{
                        return '未下载'
                    }
                } },
                { field: 'query',  title: '查询次数' },
                { fixed: 'right', minWidth: 130, title: '操作', templet:function(d){
                    return '<a href="/qrcode/qrcode/del/?ids='+d.id+'" class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>'
                }}
                
            ]
        ],
        page: {}
    });
});
</script>
{/block}